package loansManagement;

import java.io.Serializable;

import javax.persistence.Embeddable;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

import specimensManagement.Specimen;
import subscribersManagement.Subscriber;

@Embeddable
public class LoanId implements Serializable{

	public int hashCode() {
		int result;
		result = (specimen != null ? specimen.hashCode() : 0);
		result = 31 * result + (subscriber != null ? subscriber.hashCode() : 0);
		return result;
	}

	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;
		LoanId that= (LoanId) o;
		if (specimen != null ? !specimen.equals(that.specimen) : that.specimen != null) return false;
		if (subscriber != null ? !subscriber.equals(that.subscriber) : that.subscriber!= null)
			return false;

		return true;
	}

	/**
	 * @uml.property  name="specimen"
	 * @uml.associationEnd  inverse="loanId:mediasManagement.Specimen"
	 */
	@OneToOne
	private Specimen specimen;

	/**
	 * Getter of the property <tt>spec</tt>
	 * @return  Returns the spec.
	 * @uml.property  name="spec"
	 */
	public Specimen getSpecimen() {
		return specimen;
	}

	/**
	 * Setter of the property <tt>specimen</tt>
	 * @param spec  The spec to set.
	 * @uml.property  name="spec"
	 */
	public void setSpecimen(Specimen spec) {
		this.specimen = spec;
	}

	/**
	 * @uml.property  name="subscriber"
	 * @uml.associationEnd  inverse="loanId:subscribersManagement.Subscriber"
	 */
	@ManyToOne
	private Subscriber subscriber;

	/**
	 * Getter of the property <tt>subscriber</tt>
	 * @return  Returns the subscriber.
	 * @uml.property  name="subscriber"
	 */
	public Subscriber getSubscriber() {
		return subscriber;
	}

	/**
	 * Setter of the property <tt>subscriber</tt>
	 * @param subscriber  The subscriber to set.
	 * @uml.property  name="subscriber"
	 */
	public void setSubscriber(Subscriber subscriber) {
		this.subscriber = subscriber;
	}
}